package com.software.demo2.test;

import com.software.demo2.entity.User;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import java.util.Date;
import java.util.UUID;

public class Run {
    public static void main(String[] args) {
        Configuration cfg = new Configuration();
        cfg.configure();

        SessionFactory sessionFactory = cfg.buildSessionFactory();
        Session session = sessionFactory.openSession();

        Transaction transaction = session.beginTransaction();

        User user = new User(
                UUID.randomUUID().toString(),
                "class-one-demo2",
                "class-one-demo2",
                new Date()
        );
        session.save(user);

        transaction.commit();
        session.close();
        sessionFactory.close();
    }
}
